home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / poly.pro < prev    next >
Text File  |  1997-07-08  |  955b  |  53 lines

  1. ; $Id: poly.pro,v 1.3 1997/01/15 03:11:50 ali Exp $
  2. ;
  3. ; Copyright (c) 1983-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. FUNCTION POLY,X,C
  7. ;+
  8. ; NAME:
  9. ;    POLY
  10. ;
  11. ; PURPOSE:
  12. ;    Evaluate a polynomial function of a variable.
  13. ;
  14. ; CATEGORY:
  15. ;    C1 - Operations on polynomials.
  16. ;
  17. ; CALLING SEQUENCE:
  18. ;    Result = POLY(X,C)
  19. ;
  20. ; INPUTS:
  21. ;    X:    The variable.  This value can be a scalar, vector or array.
  22. ;
  23. ;    C:    The vector of polynomial coefficients.  The degree of 
  24. ;        of the polynomial is N_ELEMENTS(C) - 1.
  25. ;
  26. ; OUTPUTS:
  27. ;    POLY returns a result equal to:
  28. ;         C[0] + c[1] * X + c[2]*x^2 + ...
  29. ;
  30. ; COMMON BLOCKS:
  31. ;    None.
  32. ;
  33. ; SIDE EFFECTS:
  34. ;    None.
  35. ;
  36. ; RESTRICTIONS:
  37. ;    None.
  38. ;
  39. ; PROCEDURE:
  40. ;    Straightforward.
  41. ;
  42. ; MODIFICATION HISTORY:
  43. ;    DMS, Written, January, 1983.
  44. ;-
  45.  
  46. on_error,2        ;Return to caller if an error occurs
  47. N = N_ELEMENTS(C)-1    ;Find degree of polynomial
  48. Y = c[n]
  49. for i=n-1,0,-1 do y = y * x + c[i]
  50. return,y
  51. end
  52.  
  53.